<template>
  <div class="guide">
    <Dao :speed="10"></Dao>
  <!-- 静态轮播 -->
        <van-swipe 
            class="my-swipe" 
            :autoplay="3000" 
            indicator-color="gold"
        >
            <van-swipe-item v-for="(l,i) in imgs" :key="i">
                <img :src="l" class="g-img" alt="">
                 <van-button @click="gotowhere({name:'main'})" v-if="i==imgs.length-1" type="danger"  class="g-btn">进入App主页</van-button>
            </van-swipe-item>
        </van-swipe>
        <!-- 动态lb -->
        <!-- <van-swipe 
            class="my-swipe" 
            :autoplay="3000" 
            indicator-color="white"
        >
            <van-swipe-item v-for="(l,i) in banners" :key="i">
                <img :src="l.pic" class="g-img" alt="">
                <van-button @click="gotowhere({name:'main'})" v-if="i==banners.length-1" type="danger"  class="g-btn">进入App主页</van-button>
            </van-swipe-item>
        </van-swipe> -->
  </div>
</template>


<script>
// 引入获取一年的第几周
import {getWeekInYear} from '@/utils'

export default {
    data() {
        return {
            imgs: [
                require("@/assets/images/b1.jpg"),
                require("@/assets/images/b4.jpg"),
                require("@/assets/images/b2.jpg"),
                require("@/assets/images/b3.jpg"),
            ],
            banners: [],
            options: {
                loop: true,
                autoplay: true,
                speed: 2000,
                effect: "cube",
                cubeEffect: {
                    slideShadows: true,
                    shadow: true,
                    shadowOffset: 100,
                    shadowScale: 0.6
                },
            }
        };
    },
    methods: {
        async getBanners() {
            let res = await this.$axios.get("http://121.196.235.163:3000/banner?type=1");
            // 在下次 DOM 更新循环结束之后执行延迟回调
            this.banners = res.data.banners.slice(2, 6);
        }
    },
    mounted() {
        // this.getBanners();
    },
    // beforeRouteEnter(to,from,next){
//         const week = getWeekInYear()  // 判断今天是第几周 
//         console.log(week)

//         if(localStorage.getItem('localWeek')){
//              var localWeek = localStorage.getItem('localWeek');
//              if(week==localWeek){
//                 // 不能访问 
//                 next({name:'main'})
//                 localStorage.setItem("localWeek",week)
//              }else{
//                 next()
//              }
//         }else{
//             // 一次都没有访问过 
//             localStorage.setItem("localWeek",week)
//             next()
//         }
//     }
}
</script>

<style lang="scss" scoped>
.guide {
    width: 100%;
    height: 100%;
    padding: 0;

    .my-swipe {
        width: 100%;
        height: 100%;
    }

    #sone {
        width: 100%;
        height: 100%;
        position: relative;
    }

    .g-img {
        width: 100%;
        height: 100%;
    }

    .g-btn {
        position: absolute;
        left: 50%;
        bottom: 60px;
        transform: translateX(-50%);
        border-radius: 20px;
    }
}
</style>